// var path = "http://172.21.43.34:8080/portal/portaljs.do?";
var path = location.protocol+"//"+location.host+"/portal/portaljs.do?";

function addTab(tabId,tabName,url){
	tabId = encodeURI(encodeURI(tabId));
	tabName = encodeURI(encodeURI(tabName));
	url = encodeURI(encodeURI(url));
	
	url = replaceAll(url,"&","%26");
	url = replaceAll(url,"?","%3F");

	var ifr = document.createElement('iframe'); 
	ifr.setAttribute('id', 'ifr1'); 
	ifr.src = path + 'method=addTab&tabId='+tabId+'&tabName='+tabName+'&url='+url; 
	ifr.style.display = 'none'; 
	document.body.appendChild(ifr); 
}

function removeTab(tabId){
	tabId = encodeURI(encodeURI(tabId));

	var ifr = document.createElement('iframe'); 
	ifr.setAttribute('id', 'ifr1'); 
	ifr.src = path + 'method=removeTab&tabId='+tabId; 
	ifr.style.display = 'none'; 
	document.body.appendChild(ifr);
}

function replaceAll(str,org,targt){
	while(str.indexOf(org)>=0){
		str = str.replace(org,targt);
	}
	return str;
}

function refreshPanel(panelId){
	var ifr = document.createElement('iframe'); 
	ifr.setAttribute('id', 'ifr1'); 
	ifr.src = path + 'method=refreshPanel&tabId='+panelId; 
	ifr.style.display = 'none'; 
	document.body.appendChild(ifr);
}